<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn" xml:lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>添加文章分类</title>
  <?=HTML::style ('styles/admin/stylesheet.css')?>
  <?=HTML::script('scripts/admin/jquery/jquery-1.7.2.min.js')?>
  <?=HTML::script('scripts/admin/jquery/jquery.form.js')?>
</head>

<body>
<div id="container">
  <div class="box" style="margin:0 5px 0 15px;">
    <div class="heading">
      <h1>添加文章分类</h1>
    </div>
    <div class="content">
      <form method="post" enctype="multipart/form-data" id="form" onsubmit="return ajax_post();">
        <table class="form">
          <tr>
            <td width="120">上级分类</td>
            <td><span class="cats_select"><img src="<?=URL::site()?>images/admin/ajax-loading.gif" align="absbottom" /> <font color="gray">数据加载中…</font></span></td>
          </tr>
          <tr>
            <td>分类名称 <span class="required">*</span></td>
            <td><input type="text" size="60" maxlength="50" name="name" /> <font color="gray">不允许包含标点符号及特殊字符，字符长度：2~50</font></td>
          </tr>
          <tr>
            <td>排序</td>
            <td><input type="text" size="5"  maxlength="5" name="sort_order" value="0" /></td>
          </tr>
          <tr>
            <td>是否显示</td>
            <td>
            <label><input type="radio" name="is_show" value="1" /> 是</label> &nbsp;
            <label><input type="radio" name="is_show" value="0" checked="checked" /> 否</label> &nbsp;
            </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="button" onclick="ajax_post();" class="btn70" value="保存修改" /></td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</div>
</body>
</html>
<?=HTML::script('admin/article_category/js')?>
<script type="text/javascript">
$().ready(function(){
    $('.cats_select').html(category_select_create(0, 'parent_id'));
});

function ajax_post() {
    $.ajax({
        url  : document.location.href,
        type : 'post',
        data : $('#form').serialize(),
        dataType : 'html',
        cache : false,
        redirect : false,
        error : function(XMLHttpRequest, textStatus, errorThrown){
            alert('发生错误：' + (errorThrown?errorThrown:textStatus));
        },
        success: function(html) {
            if ($.trim(html).length > 0) {
                alert(html);
            } else {
                alert('添加分类操作成功！');
                parent.frames.treeFrame.location.reload();
                document.location.reload();
            }
        }
    });
    return false;
}
</script>